"""

    通过线程处理阻塞任务（线程用于CPU密集型工作）
        - 阻塞IO会释放GIL

"""
import functools
import time
from typing import Callable, Any


def async_timed():
    def wrapper(func: Callable):
        @functools.wraps(func)
        async def wrapped(*args: Any, **kwargs: Any) -> Any:
            print(f"有参数{args}，{kwargs}的函数{func}开始运行")
            start = time.time()
            try:
                return await func(*args, **kwargs)
            finally:
                end = time.time()
                total = end - start
                print(f"函数{func}总共花费时间：{total}s")

        return wrapped

    return wrapper
